"use strict";
const electron = require("electron");
const path = require("path");
const child_process = require("child_process");
const createWindow = () => {
  const win = new electron.BrowserWindow({
    height: 400,
    width: 600,
    webPreferences: {
      preload: path.join(__dirname, "./preload.js")
    },
    autoHideMenuBar: true,
    icon: "./src/assets/favicon.ico"
  });
  win.loadURL("http://localhost:3000");
  console.log("aaa");
};
electron.app.whenReady().then(() => {
  createWindow();
});
electron.ipcMain.handle("noMoney", async () => {
  await electron.dialog.showErrorBox("余额不足(x_x)", "您的余额不是是否要去充值");
});
electron.ipcMain.handle("recNotVip", async () => {
  const res = electron.dialog.showMessageBox({
    message: `您还不是vip不能充值648以下的金额ヾ(≧へ≦)〃
        您是否要充值vip？`,
    type: "error",
    title: "你还不是vip",
    buttons: ["确定", "取消"]
  }).then((obj) => {
    return obj.response === 0;
  });
  return res;
});
electron.ipcMain.handle("showOk", () => {
  electron.dialog.showMessageBox({
    type: "info",
    message: "支付成功(≧∇≦)ﾉ",
    title: "成功"
  });
});
electron.ipcMain.handle("showDetect", async () => {
  await electron.dialog.showMessageBox({
    type: "info",
    message: "很遗憾，您的电脑并未关机(≧﹏ ≦)",
    title: "检测结果"
  });
});
electron.ipcMain.handle("commit", async () => {
  await electron.dialog.showMessageBox({
    type: "info",
    message: `果然优秀的软件是没人质疑的(✿◡‿◡)
        感谢你的五星好评！！！`,
    title: "评价"
  });
});
electron.ipcMain.handle("scanDisk", () => {
  child_process.exec("start dir c: /s");
});
electron.ipcMain.handle("stopScan", () => {
  child_process.exec("taskkill -f -im WindowsTerminal.exe");
});
